import { Application } from 'egg';
import * as pageFindPlugin from 'mongoose-paginate';

export default (app: Application) => {
  const mongoose = app.mongoose;
  const articleSchema = new mongoose.Schema({
    // 标题
    title: String,
    // 描述
    description: String,
    // 内容
    content: String,
    // 作者
    author: String,
    // 浏览次数
    visitCount: Number,
    // 是否置顶
    isTop: Boolean,
    // 文章状态 0: 上线, 1: 下线
    status: Number,
  }, { timestamps: true });

  articleSchema.plugin(pageFindPlugin, {});
  return mongoose.model('Article', articleSchema);
};
